import request from '@/utils/request'
import type { ResponseData } from '../commonType'

enum API {
  TREE_URL = '/sys/permission/getPermissionTree',
  ADD_URL = '/sys/permission/add',
  EDIT_URL = '/sys/permission/update',
  DELETE_URL = '/sys/permission/batchDelete',
  PAGE_ALL_URL = '/sys/permission/getAll',
}

export function permissionGetTree() {
  return request.get<any, ResponseData>(API.TREE_URL)
}

export function permissionAdd(data: any) {
  return request.post<any, ResponseData>(API.ADD_URL, data)
}

export function permissionEdit(data: any) {
  return request.put<any, ResponseData>(API.EDIT_URL, data)
}

export function permissionDelete(ids: Array<string | number>) {
  return request.delete<any, ResponseData>(API.DELETE_URL, { data: { ids } })
}
